part of _;

extension on ScanQRCodePage {
  Future<void> controller_selectAssets() async {
    List<AssetEntity>? assets = await AssetUtils.selectAssets(
      requestType: RequestType.image,
    );
    if (assets == null || assets.isEmpty) return;
    yShowProgress();
    result = await Scan.parse((await assets.first.file)!.path);
    yDismissProgress();
    if (result == null) {
      yToast("识别失败");
      return;
    }
    yFinish();
  }

  void controller_toggleFlash() {
    scanController.toggleTorchMode();
    setState(() => flash_on = !flash_on);
  }
}
